package work;

public enum EnumTest {
    TEST01(1,"测试1"),
    TEST02(2,"测试2"),
    TEST03(3,"测试3");
    public Integer id;
    public String val;

    EnumTest(int id, String val) {
        this.id = id;
        this.val = val;
    }
    //通过ID获取枚举值
    public static EnumTest getById(Integer id) {
        if(id == null){
            return null;
        }
        for(EnumTest v : values()) {
            if(v.id.equals(id)) {
                return v;
            }
        }
        return null;
    }
}
